<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 4.2.1">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"emoh.xyz","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta property="og:type" content="website">
<meta property="og:title" content="Just do it!">
<meta property="og:url" content="http://emoh.xyz/page/5/index.html">
<meta property="og:site_name" content="Just do it!">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Emoh">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="http://emoh.xyz/page/5/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>Just do it!</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Just do it!</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签</a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://emoh.xyz/2020/05/27/2019-07-17-ORACLE%2011G%20RAC(Virtualbox&&Oracle%20Linux%207)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.png">
      <meta itemprop="name" content="Emoh">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Just do it!">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/05/27/2019-07-17-ORACLE%2011G%20RAC(Virtualbox&&Oracle%20Linux%207)/" class="post-title-link" itemprop="url">ORACLE 11G RAC(Virtualbox&&Oracle Linux 7)</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-05-27 10:14:16" itemprop="dateCreated datePublished" datetime="2020-05-27T10:14:16+08:00">2020-05-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-28 11:33:48" itemprop="dateModified" datetime="2020-05-28T11:33:48+08:00">2020-05-28</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/oracle-%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/" itemprop="url" rel="index"><span itemprop="name">oracle 安装配置</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">1.#&#x2F;etc&#x2F;hosts</span><br><span class="line">172.16.240.6    p730a</span><br><span class="line">172.16.240.7    p730b</span><br><span class="line">10.254.0.11     p730a-private</span><br><span class="line">10.254.0.12     p730b-private</span><br><span class="line">172.16.240.8    p730a-vip</span><br><span class="line">172.16.240.9    p730b-vip</span><br><span class="line">172.16.240.10   p730scan</span><br></pre></td></tr></table></figure>




<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br></pre></td><td class="code"><pre><span class="line">2.#网络配置</span><br><span class="line">eth0      Link encap:Ethernet  HWaddr 08:00:27:3B:20:C2  </span><br><span class="line">         inet addr:172.16.240.6  Bcast:172.16.240.255  Mask:255.255.255.0</span><br><span class="line">         inet6 addr: fe80::a00:27ff:fe3b:20c2&#x2F;64 Scope:Link</span><br><span class="line">         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1</span><br><span class="line">         RX packets:47 errors:0 dropped:0 overruns:0 frame:0</span><br><span class="line">         TX packets:59 errors:0 dropped:0 overruns:0 carrier:0</span><br><span class="line">         collisions:0 txqueuelen:1000</span><br><span class="line">         RX bytes:8503 (8.3 KiB)  TX bytes:8867 (8.6 KiB)</span><br><span class="line">eth1      Link encap:Ethernet  HWaddr 08:00:27:02:28:2E  </span><br><span class="line">         inet addr:10.254.0.11  Bcast:10.254.0.255  Mask:255.255.255.0</span><br><span class="line">         inet6 addr: fe80::a00:27ff:fe02:282e&#x2F;64 Scope:Link</span><br><span class="line">         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1</span><br><span class="line">         RX packets:40 errors:0 dropped:0 overruns:0 frame:0</span><br><span class="line">         TX packets:59 errors:0 dropped:0 overruns:0 carrier:0</span><br><span class="line">         collisions:0 txqueuelen:1000</span><br><span class="line">         RX bytes:6546 (6.3 KiB)  TX bytes:8909 (8.7 KiB)</span><br><span class="line">eth2      Link encap:Ethernet  HWaddr 08:00:27:DE:5D:EA  </span><br><span class="line">         inet addr:172.40.4.187  Bcast:172.40.4.255  Mask:255.255.255.0</span><br><span class="line">         inet6 addr: fe80::a00:27ff:fede:5dea&#x2F;64 Scope:Link</span><br><span class="line">         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1</span><br><span class="line">         RX packets:105 errors:0 dropped:0 overruns:0 frame:0</span><br><span class="line">         TX packets:141 errors:0 dropped:0 overruns:0 carrier:0</span><br><span class="line">         collisions:0 txqueuelen:1000</span><br><span class="line">         RX bytes:16692 (16.3 KiB)  TX bytes:19740 (19.2 KiB)</span><br><span class="line">3.#安装需求包</span><br><span class="line">binutils-2.17.50.0.6</span><br><span class="line">compat-libstdc++-33-3.2.3</span><br><span class="line">elfutils-libelf-0.125</span><br><span class="line">elfutils-libelf-devel-0.125</span><br><span class="line">elfutils-libelf-devel-static-0.125</span><br><span class="line">gcc-4.1.2</span><br><span class="line">gcc-c++-4.1.2</span><br><span class="line">glibc-2.5-24</span><br><span class="line">glibc-common-2.5</span><br><span class="line">glibc-devel-2.5</span><br><span class="line">glibc-headers-2.5</span><br><span class="line">kernel-headers-2.6.18</span><br><span class="line">ksh-20060214</span><br><span class="line">libaio-0.3.106</span><br><span class="line">libaio-devel-0.3.106</span><br><span class="line">libgcc-4.1.2</span><br><span class="line">libgomp-4.1.2</span><br><span class="line">libstdc++-4.1.2</span><br><span class="line">libstdc++-devel-4.1.2</span><br><span class="line">make-3.81</span><br><span class="line">sysstat-7.0.2</span><br><span class="line">unixODBC-2.2.11</span><br><span class="line">unixODBC-devel-2.2.11</span><br><span class="line">4.#修改操作系统参数</span><br><span class="line">&#x2F;etc&#x2F;security&#x2F;limits.conf</span><br><span class="line">oracle soft nproc 2047</span><br><span class="line">oracle hard nproc 16384</span><br><span class="line">oracle soft nofile 1024</span><br><span class="line">oracle hard nofile 65536</span><br><span class="line">grid soft nproc 2047</span><br><span class="line">grid hard nproc 16384</span><br><span class="line">grid soft nofile 1024</span><br><span class="line">grid hard nofile 65536</span><br><span class="line">将以下内容添加到文件 &#x2F;etc&#x2F;sysctl.conf并运行：sysctl -p 。</span><br><span class="line">fs.aio-max-nr &#x3D; 1048576</span><br><span class="line">fs.file-max &#x3D; 6815744</span><br><span class="line">kernel.shmall &#x3D; 2097152</span><br><span class="line">kernel.shmmax &#x3D; 2076407808</span><br><span class="line">kernel.shmmni &#x3D; 4096</span><br><span class="line">kernel.sem &#x3D; 250 32000 100 128</span><br><span class="line">net.ipv4.ip_local_port_range &#x3D; 9000 65500</span><br><span class="line">net.core.rmem_default &#x3D; 262144</span><br><span class="line">net.core.rmem_max &#x3D; 4194304</span><br><span class="line">net.core.wmem_default &#x3D; 262144</span><br><span class="line">net.core.wmem_max &#x3D; 1048586</span><br><span class="line">将以下内容添加到文件&#x2F;etc&#x2F;pam.d&#x2F;login。</span><br><span class="line">session required pam_limits.so</span><br><span class="line">5.#创建用户</span><br><span class="line">groupadd -g 500 oinstall</span><br><span class="line">groupadd -g 501 dba</span><br><span class="line">groupadd -g 502 oper</span><br><span class="line">groupadd -g 600 asmadmin</span><br><span class="line">groupadd -g 601 asmoper</span><br><span class="line">groupadd -g 602 asmdba</span><br><span class="line">useradd -g oinstall -G dba,asmdba,oper oracle</span><br><span class="line">useradd -g oinstall -G asmadmin,asmdba,asmoper,dba grid</span><br><span class="line">mkdir -p &#x2F;oracle&#x2F;app&#x2F;grid</span><br><span class="line">mkdir -p &#x2F;oracle&#x2F;app&#x2F;oracle&#x2F;product&#x2F;11.2.0&#x2F;</span><br><span class="line">chown -R oracle:oinstall &#x2F;oracle</span><br><span class="line">chmod -R 775 &#x2F;oracle</span><br><span class="line">su - oracle</span><br><span class="line">vi .bash_profile</span><br><span class="line">添加以下内容</span><br><span class="line">DISPLAY&#x3D;172.40.1.169:0.0</span><br><span class="line">export DISPLAY</span><br><span class="line">export PATH</span><br><span class="line">export ORACLE_BASE&#x3D;&#x2F;oracle&#x2F;app&#x2F;oracle</span><br><span class="line">export ORACLE_HOME&#x3D;&#x2F;oracle&#x2F;app&#x2F;oracle&#x2F;product&#x2F;11.2.0&#x2F;</span><br><span class="line">export PATH&#x3D;$ORACLE_HOME&#x2F;bin:$PATH</span><br><span class="line">export ORACLE_SID&#x3D;etyyhis1</span><br><span class="line">umask 0022</span><br><span class="line">su - grid</span><br><span class="line">vi .bash_profile</span><br><span class="line">添加以下内容</span><br><span class="line">DISPLAY&#x3D;172.40.1.169:0.0</span><br><span class="line">export DISPLAY</span><br><span class="line">export PATH</span><br><span class="line">export ORACLE_BASE&#x3D;&#x2F;oracle&#x2F;app&#x2F;grid&#x2F;</span><br><span class="line">export ORACLE_HOME&#x3D;&#x2F;oracle&#x2F;app&#x2F;11.2.0&#x2F;grid</span><br><span class="line">export PATH&#x3D;$ORACLE_HOME&#x2F;bin:$PATH</span><br><span class="line">export ORACLE_SID&#x3D;+ASM1</span><br><span class="line">umask 0022</span><br><span class="line">6.安装ASMLIB</span><br><span class="line">创建共享磁盘</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\asm1.vdi -size 5120 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\asm2.vdi -size 5120 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\asm3.vdi -size 5120 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\asm4.vdi -size 5120 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\asm5.vdi -size 5120 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\data1.vdi -size 10240 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\data2.vdi -size 10240 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\data3.vdi -size 10240 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\data4.vdi -size 10240 -format VDI -variant Fixed</span><br><span class="line">VBoxManage.exe createhd -filename d:\vms\sharedisk\data5.vdi -size 10240 -format VDI -variant Fixed</span><br><span class="line">连接共享磁盘到RAC1</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 1 --device 0 --type hdd --medium d:\vms\sharedisk\asm1.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 2 --device 0 --type hdd --medium d:\vms\sharedisk\asm2.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 3 --device 0 --type hdd --medium d:\vms\sharedisk\asm3.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 4 --device 0 --type hdd --medium d:\vms\sharedisk\asm4.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 5 --device 0 --type hdd --medium d:\vms\sharedisk\asm5.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 6 --device 0 --type hdd --medium d:\vms\sharedisk\data1.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 7 --device 0 --type hdd --medium d:\vms\sharedisk\data2.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 8 --device 0 --type hdd --medium d:\vms\sharedisk\data3.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 9 --device 0 --type hdd --medium d:\vms\sharedisk\data4.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac1 --storagectl &quot;SATA 控制器&quot; --port 10 --device 0 --type hdd --medium d:\vms\sharedisk\data5.vdi --mtype shareable</span><br><span class="line">共享共享磁盘</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\asm1.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\asm2.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\asm3.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\asm4.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\asm5.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\data1.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\data2.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\data3.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\data4.vdi --type shareable</span><br><span class="line">VBoxManage.exe modifyhd d:\vms\sharedisk\data5.vdi --type shareable</span><br><span class="line">连接共享磁盘到RAC2</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 1 --device 0 --type hdd --medium d:\vms\sharedisk\asm1.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 2 --device 0 --type hdd --medium d:\vms\sharedisk\asm2.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 3 --device 0 --type hdd --medium d:\vms\sharedisk\asm3.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 4 --device 0 --type hdd --medium d:\vms\sharedisk\asm4.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 5 --device 0 --type hdd --medium d:\vms\sharedisk\asm5.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 6 --device 0 --type hdd --medium d:\vms\sharedisk\data1.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 7 --device 0 --type hdd --medium d:\vms\sharedisk\data2.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 8 --device 0 --type hdd --medium d:\vms\sharedisk\data3.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 9 --device 0 --type hdd --medium d:\vms\sharedisk\data4.vdi --mtype shareable</span><br><span class="line">VBoxManage.exe storageattach rac2 --storagectl &quot;SATA 控制器&quot; --port 10 --device 0 --type hdd --medium d:\vms\sharedisk\data5.vdi --mtype shareable</span><br><span class="line">rpm -ivh oracleasm-support-2.1.5-1.el6.x86_64.rpm</span><br><span class="line">rpm -ivh oracleasmlib-2.0.4-1.el6.x86_64.rpm</span><br><span class="line">查看磁盘 ls -l &#x2F;dev&#x2F;sd*</span><br><span class="line">磁盘分区 fdisk &#x2F;dev&#x2F;sdb</span><br><span class="line">******************</span><br><span class="line">[root@p730a ~]# fdisk &#x2F;dev&#x2F;sdf</span><br><span class="line">Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel</span><br><span class="line">Building a new DOS disklabel with disk identifier 0xfd5d3b90.</span><br><span class="line">Changes will remain in memory only, until you decide to write them.</span><br><span class="line">After that, of course, the previous content won&#39;t be recoverable.</span><br><span class="line">Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)</span><br><span class="line">WARNING: DOS-compatible mode is deprecated. It&#39;s strongly recommended to</span><br><span class="line">        switch off the mode (command &#39;c&#39;) and change display units to</span><br><span class="line">        sectors (command &#39;u&#39;).</span><br><span class="line">Command (m for help): n</span><br><span class="line">Command action</span><br><span class="line">  e   extended</span><br><span class="line">  p   primary partition (1-4)</span><br><span class="line">p</span><br><span class="line">Partition number (1-4): 1</span><br><span class="line">First cylinder (1-652, default 1):</span><br><span class="line">Using default value 1</span><br><span class="line">Last cylinder, +cylinders or +size&#123;K,M,G&#125; (1-652, default 652):</span><br><span class="line">Using default value 652</span><br><span class="line">Command (m for help): p</span><br><span class="line">Disk &#x2F;dev&#x2F;sdf: 5368 MB, 5368709120 bytes</span><br><span class="line">255 heads, 63 sectors&#x2F;track, 652 cylinders</span><br><span class="line">Units &#x3D; cylinders of 16065 * 512 &#x3D; 8225280 bytes</span><br><span class="line">Sector size (logical&#x2F;physical): 512 bytes &#x2F; 512 bytes</span><br><span class="line">I&#x2F;O size (minimum&#x2F;optimal): 512 bytes &#x2F; 512 bytes</span><br><span class="line">Disk identifier: 0xfd5d3b90</span><br><span class="line">  Device Boot      Start         End      Blocks   Id  System</span><br><span class="line">&#x2F;dev&#x2F;sdf1               1         652     5237158+  83  Linux</span><br><span class="line">Command (m for help): w</span><br><span class="line">The partition table has been altered!</span><br><span class="line">Calling ioctl() to re-read partition table.</span><br><span class="line">Syncing disks.</span><br><span class="line">****************************</span><br><span class="line">其他磁盘雷同</span><br><span class="line">初始化ASM</span><br><span class="line">****************************</span><br><span class="line">[root@p730a ~]# oracleasm configure -i</span><br><span class="line">Configuring the Oracle ASM library driver.</span><br><span class="line">This will configure the on-boot properties of the Oracle ASM library</span><br><span class="line">driver.  The following questions will determine whether the driver is</span><br><span class="line">loaded on boot and what permissions it will have.  The current values</span><br><span class="line">will be shown in brackets (&#39;[]&#39;).  Hitting &lt;ENTER&gt; without typing an</span><br><span class="line">answer will keep that current value.  Ctrl-C will abort.</span><br><span class="line">Default user to own the driver interface []: grid</span><br><span class="line">Default group to own the driver interface []: dba</span><br><span class="line">Start Oracle ASM library driver on boot (y&#x2F;n) [n]: y</span><br><span class="line">Scan for Oracle ASM disks on boot (y&#x2F;n) [y]: y</span><br><span class="line">Writing Oracle ASM library driver configuration: done</span><br><span class="line">****************************</span><br><span class="line">[root@p730a ~]# oracleasm init</span><br><span class="line">Creating &#x2F;dev&#x2F;oracleasm mount point: &#x2F;dev&#x2F;oracleasm</span><br><span class="line">Loading module &quot;oracleasm&quot;: oracleasm</span><br><span class="line">Mounting ASMlib driver filesystem: &#x2F;dev&#x2F;oracleasm</span><br><span class="line">****************************</span><br><span class="line">创建ASM磁盘</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK1 &#x2F;dev&#x2F;sdb1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK2 &#x2F;dev&#x2F;sdc1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK3 &#x2F;dev&#x2F;sdd1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK4 &#x2F;dev&#x2F;sde1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK5 &#x2F;dev&#x2F;sdf1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK6 &#x2F;dev&#x2F;sdg1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK7 &#x2F;dev&#x2F;sdh1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK8 &#x2F;dev&#x2F;sdi1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK9 &#x2F;dev&#x2F;sdj1</span><br><span class="line">&#x2F;usr&#x2F;sbin&#x2F;oracleasm createdisk DISK10 &#x2F;dev&#x2F;sdk1</span><br><span class="line">7:创建RAC2主机</span><br><span class="line">VBoxManage.exe clonehd d:\vms\rac1\rac1.vdi d:\vms\rac2\rac2.vdi</span><br><span class="line">修改rac2主机的主机名，IP，相关用户的环境变量</span><br><span class="line">8.SSH等效性</span><br><span class="line">分别su - grid  su - oracle 执行以下命令</span><br><span class="line">在节点一执行：</span><br><span class="line">mkdir ~&#x2F;.ssh</span><br><span class="line">chmod 700 ~&#x2F;.ssh</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;ssh-keygen -t dsa</span><br><span class="line">在节点二上执行</span><br><span class="line">mkdir ~&#x2F;.ssh</span><br><span class="line">chmod 700 ~&#x2F;.ssh</span><br><span class="line">&#x2F;usr&#x2F;bin&#x2F;ssh-keygen -t dsa</span><br><span class="line">在节点一上执行</span><br><span class="line">cat ~&#x2F;.ssh&#x2F;id_dsa.pub &gt;&gt; ~&#x2F;.ssh&#x2F;authorized_keys</span><br><span class="line">ssh p730b cat ~&#x2F;.ssh&#x2F;id_dsa.pub &gt;&gt; ~&#x2F;.ssh&#x2F;authorized_keys</span><br><span class="line">scp ~&#x2F;.ssh&#x2F;authorized_keys p730b:~&#x2F;.ssh&#x2F;authorized_keys</span><br><span class="line">9.安装grid</span><br><span class="line">.&#x2F;runcluvfy.sh stage -pre crsinst -n p730a,p730b -fixup -verbos</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://emoh.xyz/2020/05/27/2019-07-17-ORACLE%2011G%20DataGuard%20%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.png">
      <meta itemprop="name" content="Emoh">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Just do it!">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/05/27/2019-07-17-ORACLE%2011G%20DataGuard%20%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2/" class="post-title-link" itemprop="url">ORACLE 11G DataGuard 安装部署</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-05-27 10:14:16" itemprop="dateCreated datePublished" datetime="2020-05-27T10:14:16+08:00">2020-05-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-28 11:33:44" itemprop="dateModified" datetime="2020-05-28T11:33:44+08:00">2020-05-28</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/oracle-%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AE/" itemprop="url" rel="index"><span itemprop="name">oracle 安装配置</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ol>
<li>修改主库参数</li>
</ol>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> db_unique_name=<span class="string">'etyyhis'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_config=<span class="string">'dg_config=(etyyhis,etyyhisdg)'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_dest_1=<span class="string">'location=+DGRECOVER valid_for=(all_logfiles,all_roles) db_unique_name=etyyhis'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_dest_2=<span class="string">'service=etyyhisdg lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=etyyhisdg'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_dest_2=<span class="string">'service=etyyhisdg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=etyyhisdg'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>; <span class="comment">#最高可用模式</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_max_processes=<span class="number">6</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> fal_server=<span class="string">'etyyhisdg'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> fal_client=<span class="string">'etyyhis'</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> standby_file_management=<span class="keyword">auto</span> <span class="keyword">scope</span>=<span class="keyword">both</span> <span class="keyword">sid</span>=<span class="string">'*'</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> db_file_name_convert=<span class="string">'+DGDATA'</span>,<span class="string">'+DGDATA'</span> <span class="keyword">scope</span>=<span class="keyword">spfile</span> <span class="keyword">sid</span>=<span class="string">'*'</span>; <span class="comment">#参数需要重启生效，用于备库文件路径转换</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_file_name_convert=<span class="string">'+DGDATA'</span>,<span class="string">'+DGDATA'</span> <span class="keyword">scope</span>=<span class="keyword">spfile</span> <span class="keyword">sid</span>=<span class="string">'*'</span>; <span class="comment">#参数需要重启生效，用于备库文件路径转换</span></span><br><span class="line">SQL&gt; alter database force logging;</span><br></pre></td></tr></table></figure>



<ol start="2">
<li>修改监听和TNSNAME</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br></pre></td><td class="code"><pre><span class="line">etyyhis =</span><br><span class="line"> (DESCRIPTION =</span><br><span class="line">   (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.240.10)(PORT = 1521))</span><br><span class="line">   (CONNECT_DATA =</span><br><span class="line">     (SERVER = DEDICATED)</span><br><span class="line">     (SERVICE_NAME = etyyhis)</span><br><span class="line">   )</span><br><span class="line"> )</span><br><span class="line">etyyhisdg =</span><br><span class="line"> (DESCRIPTION =</span><br><span class="line">   (ADDRESS = (PROTOCOL = TCP)(HOST=172.16.240.20)(PORT = 1521))</span><br><span class="line">   (CONNECT_DATA =</span><br><span class="line">     (SERVER = DEDICATED)</span><br><span class="line">     (SERVICE_NAME = etyyhisdg)</span><br><span class="line">     (SID=etyyhis)</span><br><span class="line">         (UR=A)</span><br><span class="line">   )</span><br><span class="line">)</span><br><span class="line">etyyhis1 =</span><br><span class="line"> (DESCRIPTION =</span><br><span class="line">   (ADDRESS = (PROTOCOL = TCP)(HOST=172.16.240.8)(PORT = 1521))</span><br><span class="line">   (CONNECT_DATA =</span><br><span class="line">     (SERVER = DEDICATED)</span><br><span class="line">     (SERVICE_NAME = etyyhis)</span><br><span class="line">     (SID=etyyhis1)</span><br><span class="line">   )</span><br><span class="line"> )</span><br><span class="line">etyyhis2 =</span><br><span class="line"> (DESCRIPTION =</span><br><span class="line">   (ADDRESS = (PROTOCOL = TCP)(HOST=172.16.240.9)(PORT = 1521))</span><br><span class="line">   (CONNECT_DATA =</span><br><span class="line">     (SERVER = DEDICATED)</span><br><span class="line">     (SERVICE_NAME = etyyhis)</span><br><span class="line">     (SID=etyyhis2)</span><br><span class="line"> )</span><br><span class="line"> )</span><br></pre></td></tr></table></figure>

<ol start="3">
<li>拷贝PFILE ，密码文件到备库,创建备库文件系统</li>
</ol>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle]%mkdir fast_recovery_area</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle]%mkdir -p ./oradata/oraclebird</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle]%mkdir -p ./diag/rdbms/etyyhis/etyyhis</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle]%<span class="built_in">cd</span> ./diag/rdbms/etyyhis/etyyhis</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle/diag/rdbms/oraclebird/oraclebird]%mkdir alert  cdump  hm  incident  incpkg  ir  lck  metadata  metadata_dgif  metadata_pv  stage  sweep  trace</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle]%mkdir -p ./admin/etyyhis/</span><br><span class="line">[oracle@ora-lab2 /u01/app/product/11.2.0/oracle/admin/oraclebird]%mkdir adump  dpdump  pfile</span><br></pre></td></tr></table></figure>

<ol start="4">
<li>修改备库参数</li>
</ol>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">*.db_unique_name=etyyhisdg</span><br><span class="line">*.log_archive_config='dg_config=(etyyhis,etyyhisdg)'</span><br><span class="line">*.log_archive_dest_1='location=+DGRECOVER  valid_for=(all_logfiles,all_roles) db_unique_name=etyyhisdg'</span><br><span class="line">*.log_archive_dest_2='service=etyyhis lgwr async valid_for=(online_logfiles,primary_role)  db_unique_name=etyyhis'</span><br><span class="line">*.log_archive_max_processes=6</span><br><span class="line">*.fal_server='etyyhis'</span><br><span class="line">*.fal_client='etyyhisdg'</span><br><span class="line">*.standby_file_management=auto</span><br><span class="line">*.db_file_name_convert='+DGDATA','+DGDATA'</span><br><span class="line">*.log_file_name_convert='+DGDATA','+DGDATA'</span><br></pre></td></tr></table></figure>

<ol start="5">
<li>备份主库，恢复备库</li>
</ol>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">mkdir /u01/rman</span><br><span class="line">rman target /</span><br><span class="line">RMAN&gt; backup database format '/u01/rman/db_%d_%s_%p_%u_%T.dbf';</span><br><span class="line">RMAN&gt; sql 'alter system archive log current';</span><br><span class="line">RMAN&gt; backup archivelog all format '/u01/rman/arc_%d_%s_%p_%u_%T.arc';</span><br><span class="line">RMAN&gt;backup current controlfile for standby format '/u01/rman/ctl_sty__%d_%s_%p_%u_%T.dbf';</span><br><span class="line">rman target /</span><br><span class="line">RMAN&gt; startup nomount;</span><br><span class="line">RMAN&gt;restore controlfile from '/u01/rman/ctl_sty__ETYYHIS_10_1_0aqahqmh_20150627.dbf';</span><br><span class="line">RMAN&gt;sql 'alter database mount';</span><br><span class="line">RMAN&gt; list backup;</span><br><span class="line">RMAN&gt; restore database;</span><br><span class="line">RMAN&gt; recover database;</span><br><span class="line">RMAN&gt; exit</span><br></pre></td></tr></table></figure>

<ol start="6">
<li>添加主备库standby logfile</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line">查看当前在线日志情况</span><br><span class="line"><span class="keyword">select</span> inst_id,<span class="keyword">count</span>(<span class="number">1</span>),<span class="keyword">max</span>(<span class="keyword">bytes</span>) <span class="keyword">from</span> gv$<span class="keyword">log</span> <span class="keyword">group</span> <span class="keyword">by</span> inst_id;</span><br><span class="line">备库</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">5</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_05.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">6</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_06.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">7</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_07.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">8</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_08.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">9</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_09.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line">假如需要删除日志</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">5</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">6</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">7</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">8</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">9</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">10</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">11</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">12</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">13</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">drop</span> <span class="keyword">logfile</span> <span class="keyword">group</span> <span class="number">14</span>;</span><br><span class="line">主库，RAC需要加两个thread，每个thread比在线日志多一组</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">1</span> <span class="keyword">group</span> <span class="number">5</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_05.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">1</span> <span class="keyword">group</span> <span class="number">6</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_06.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">1</span> <span class="keyword">group</span> <span class="number">7</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_07.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">1</span> <span class="keyword">group</span> <span class="number">8</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_08.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">1</span> <span class="keyword">group</span> <span class="number">9</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_09.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">2</span> <span class="keyword">group</span> <span class="number">10</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_10.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">2</span> <span class="keyword">group</span> <span class="number">11</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_11.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">2</span> <span class="keyword">group</span> <span class="number">12</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_12.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">2</span> <span class="keyword">group</span> <span class="number">13</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_13.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">add</span> <span class="keyword">standby</span> <span class="keyword">logfile</span> <span class="keyword">thread</span> <span class="number">2</span> <span class="keyword">group</span> <span class="number">14</span> (<span class="string">'+DGDATA/etyyhis/standbylog/standby_group_14.log'</span>) <span class="keyword">size</span> <span class="number">50</span>m;</span><br></pre></td></tr></table></figure>

<ol start="7">
<li>启动备库日志应用</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">startup nomount</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">mount</span> <span class="keyword">standby</span> <span class="keyword">database</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">using</span> <span class="keyword">current</span> <span class="keyword">logfile</span> <span class="keyword">disconnect</span> <span class="keyword">from</span> <span class="keyword">session</span>;</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span>  <span class="keyword">disconnect</span> <span class="keyword">from</span> <span class="keyword">session</span>;</span><br></pre></td></tr></table></figure>

<ol start="8">
<li>启动ADG</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">打开物理DG时查询功能(active dataguard)。</span><br><span class="line">SQL&gt; ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;</span><br><span class="line">SQL&gt; ALTER DATABASE OPEN;</span><br><span class="line">SQL&gt; select open_mode from v$database;</span><br><span class="line">OPEN_MODE</span><br><span class="line"><span class="comment">--------------------</span></span><br><span class="line">READ ONLY</span><br><span class="line">SQL&gt; ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;</span><br><span class="line">SQL&gt; select open_mode from v$database;</span><br><span class="line">OPEN_MODE</span><br><span class="line"><span class="comment">--------------------</span></span><br><span class="line">READ ONLY <span class="keyword">WITH</span> <span class="keyword">APPLY</span></span><br><span class="line">也就是说，在正常启动 <span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span>后，需要再执行几个语句，才能将<span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span> 变为active dataguard状态</span><br></pre></td></tr></table></figure>

<ol start="9">
<li>修改主库的DG模式（最大性能模式）</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> database_role,protection_mode,protection_level <span class="keyword">from</span> v$<span class="keyword">database</span>; <span class="comment">#查看当前保护模式</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">set</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">to</span> <span class="keyword">maximize</span> <span class="keyword">availability</span>; <span class="comment">#修改为最高可用模式</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">set</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">to</span> <span class="keyword">maximize</span> <span class="keyword">protection</span>; <span class="comment">#修改为最大保护模式</span></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">set</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">to</span> <span class="keyword">maximize</span> <span class="keyword">performance</span>; <span class="comment">#修改为最高性能模式</span></span><br><span class="line">1、最高性能模式既可以使用ARCH方式传递日志，也可以使用LGWR方式传递，在升级到更高级别保护模式时，需使用LGWR方式，且需要在备库创建standby日志组。</span><br><span class="line">2、三种保护模式进行切换时，最高性能升级到最大保护模式（⑤），需先把数据库重启到mounted状态才能操作。其他情况（①②③④⑥）相互切换时，可以直接进行。</span><br><span class="line">根据实验结论，在生产环境下如果需要从最高性能模式升级为最大保护模式，可先从最高性能模式升级最高可用模式，再由最高可用模式升级为最大保护模式。</span><br><span class="line">如下图，通过①②分步升级的方式代替⑤直接升级,避免了重启到mounted状态对生产环境下业务造成的影响。</span><br><span class="line">1.最大保护模式</span><br><span class="line">1）这种模式提供了最高级别的数据保护能力；</span><br><span class="line">2）要求至少一个物理备库收到重做日志后，主库的事务才能够提交；</span><br><span class="line">3）主库找不到合适的备库写入时，主库会自动关闭，防止未受保护的数据出现；</span><br><span class="line">4）优点：该模式可以保证备库没有数据丢失；</span><br><span class="line">5）缺点：主库的自动关闭会影响到主库的可用性，同时需要备库恢复后才能提交，对网络等客观条件要求非常的高，主库的性能会因此受到非常大的冲击。</span><br><span class="line">2.最大可用性模式</span><br><span class="line">1）该模式提供了仅次于"最大保护模式"的数据保护能力；</span><br><span class="line">2）要求至少一个物理备库收到重做日志后，主库的事务才能够提交；</span><br><span class="line">3）主库找不到合适的备库写入时，主库不会关闭，而是临时降低到"最大性能模式"模式，直到问题得到处理；</span><br><span class="line">4）优点：该模式可以在没有问题出现的情况下，保证备库没有数据丢失，是一种折中的方法；</span><br><span class="line">5）缺点：在正常运行的过程中缺点是主库的性能受到诸多因素的影响。</span><br><span class="line">3.最大性能模式</span><br><span class="line">1）该模式是默认模式，可以保证主数据库的最高可用性；</span><br><span class="line">2）保证主库运行过程中不受备库的影响，主库事务正常提交，不因备库的任何问题影响到主库的运行；</span><br><span class="line">4）优点：避免了备库对主数据库的性能和可用性影响；</span><br><span class="line">5）缺点：如果与主库提交的事务相关的恢复数据没有发送到备库，这些事务数据将被丢失，不能保证数据无损失；</span><br></pre></td></tr></table></figure>


<ol start="10">
<li>DG的监控</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">sequence</span><span class="comment">#,applied,status from v$archived_log;#查看日志归档情况</span></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">sequence</span><span class="comment">#,status from v$log; #主、备库查看当前日志状况</span></span><br><span class="line"><span class="keyword">select</span> process, <span class="keyword">sequence</span><span class="comment">#, status, delay_mins from v$managed_standby; #备库查看RFS接收日志和MRP应用日志同步主库情况</span></span><br><span class="line"><span class="keyword">select</span> archived_thread<span class="comment">#,archived_seq#,applied_thread#,applied_seq# from v$archive_dest_status; #查看主备同步情况</span></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">status</span>,gap_status <span class="keyword">from</span> v$archive_dest_status <span class="keyword">where</span> dest_id=<span class="number">2</span>; <span class="comment">#查看是否有GAP,如果有GAP一定要及时检查解决</span></span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> v$archive_gap; <span class="comment">#查看主备是否有gap</span></span><br><span class="line"><span class="keyword">select</span> <span class="keyword">thread</span><span class="comment">#,sequence#,first_change#,next_change# from v$log_history; #备库查看已经应用的归档</span></span><br><span class="line"><span class="keyword">select</span> REGISTRAR,CREATOR,<span class="keyword">THREAD</span><span class="comment">#,APPLIED,sequence#,first_change#,next_change#, COMPLETION_TIME from v$archived_log; #备库查看已经归档的日志</span></span><br><span class="line">监控 <span class="built_in">real</span>-<span class="built_in">time</span> <span class="keyword">apply</span> 实时同步的dataguard 是否正常同步：</span><br><span class="line"><span class="keyword">select</span> to_char(<span class="keyword">SYSDATE</span>,<span class="string">'yyyymmdd hh24:mi:ss'</span>) CTIME,<span class="keyword">NAME</span>,<span class="keyword">VALUE</span>,DATUM_TIME <span class="keyword">from</span> V$DATAGUARD_STATS <span class="keyword">WHERE</span> <span class="keyword">NAME</span> <span class="keyword">LIKE</span> <span class="string">'%lag'</span>;</span><br><span class="line">其中如果apply lag对应的value大于0，那么就需要注意检查是否同步正常。如果相差时间非常多，value值等于几分钟，甚至达到1个小时，那可能实时同步有问题，需要检查 alert log 文件，其中会提示是否启动了real time apply, 检查最近的log，可以发现：</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">using</span> <span class="keyword">current</span> <span class="keyword">logfile</span> <span class="keyword">disconnect</span> <span class="keyword">from</span> <span class="keyword">session</span></span><br><span class="line">MRP0 started <span class="keyword">with</span> pid=<span class="number">20</span>, OS <span class="keyword">id</span>=<span class="number">647263927</span></span><br><span class="line"><span class="keyword">Managed</span> <span class="keyword">Standby</span> <span class="keyword">Recovery</span> <span class="keyword">starting</span> <span class="built_in">Real</span> <span class="built_in">Time</span> <span class="keyword">Apply</span></span><br></pre></td></tr></table></figure>

<ol start="11">
<li>数据同步验证</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">主库创建表空间</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">tablespace</span> <span class="keyword">user_data</span>  </span><br><span class="line"><span class="keyword">logging</span>  </span><br><span class="line"><span class="keyword">datafile</span> <span class="string">'+DGDATA'</span></span><br><span class="line"><span class="keyword">size</span> <span class="number">50</span>m  </span><br><span class="line"><span class="keyword">autoextend</span> <span class="keyword">on</span>  </span><br><span class="line"><span class="keyword">next</span> <span class="number">50</span>m <span class="keyword">maxsize</span> <span class="number">20480</span>m  </span><br><span class="line"><span class="keyword">extent</span> <span class="keyword">management</span> <span class="keyword">local</span>;  </span><br><span class="line">创建表</span><br><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> testid</span><br><span class="line">(</span><br><span class="line">username   <span class="built_in">varchar2</span>(<span class="number">60</span>),  </span><br><span class="line"><span class="keyword">id</span>         <span class="built_in">varchar2</span>(<span class="number">50</span>)  </span><br><span class="line">)</span><br><span class="line"><span class="keyword">tablespace</span> <span class="keyword">user_data</span>;</span><br><span class="line">插入数据</span><br><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> testid(username) <span class="keyword">values</span>(<span class="string">'aa'</span>);</span><br><span class="line"><span class="keyword">commit</span>;</span><br><span class="line">备库</span><br><span class="line"><span class="keyword">select</span> * <span class="keyword">from</span> testid;</span><br><span class="line">可以看到数据马上就同步过来了</span><br></pre></td></tr></table></figure>

<ol start="12">
<li>主备切换</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">查看状态</span><br><span class="line"><span class="keyword">select</span> open_mode,database_role,switchover_status <span class="keyword">from</span> v$<span class="keyword">database</span>;</span><br><span class="line">物理standby切换步骤:</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">disconnect</span> <span class="keyword">from</span> <span class="keyword">session</span>; 开启MRP应用</span><br><span class="line"></span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">cancel</span>;关闭MRP应用进程</span><br><span class="line"></span><br><span class="line">在主库执行切换至standby：</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">COMMIT</span> <span class="keyword">TO</span> <span class="keyword">SWITCHOVER</span> <span class="keyword">TO</span> <span class="keyword">PHYSICAL</span> <span class="keyword">STANDBY</span>;</span><br><span class="line">SHUTDOWN IMMEDIATE;</span><br><span class="line">STARTUP NOMOUNT;</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">MOUNT</span> <span class="keyword">STANDBY</span> <span class="keyword">DATABASE</span>;</span><br><span class="line">在备库执行切换至primary:</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">COMMIT</span> <span class="keyword">TO</span> <span class="keyword">SWITCHOVER</span> <span class="keyword">TO</span> PRIMARY;</span><br><span class="line">SHUTDOWN IMMEDIATE;</span><br><span class="line">STARTUP;</span><br><span class="line">在主库执行启动MRP:</span><br><span class="line"><span class="keyword">ALTER</span> <span class="keyword">DATABASE</span> <span class="keyword">RECOVER</span> <span class="keyword">MANAGED</span> <span class="keyword">STANDBY</span> <span class="keyword">DATABASE</span> <span class="keyword">DISCONNECT</span> <span class="keyword">FROM</span> <span class="keyword">SESSION</span>;</span><br><span class="line">如果主库DOWN机，我们可以在备库执行以下指令直接激活备库:</span><br><span class="line"><span class="keyword">Alter</span> <span class="keyword">DATABASE</span> <span class="keyword">RECOVER</span> <span class="keyword">MANAGED</span> <span class="keyword">STANDBY</span> <span class="keyword">DATABASE</span> <span class="keyword">FINISH</span>;</span><br><span class="line"><span class="keyword">Alter</span> <span class="keyword">DATABASE</span> <span class="keyword">COMMIT</span> <span class="keyword">TO</span> <span class="keyword">SWITCHOVER</span> <span class="keyword">TO</span> PRIMARY;</span><br><span class="line">SHUTDOWN IMMEDIATE;</span><br><span class="line">STARTUP;</span><br><span class="line">附一份DG主备库切换状态说明：</span><br><span class="line">v$database</span><br><span class="line">NOT ALLOWED - On a primary database, this status indicates that there are no valid and enabled standby databases. On a standby database, this status indicates that a switchover request has not been received from the primary database.</span><br><span class="line">SESSIONS ACTIVE - The database has active sessions. On a physical standby database, the <span class="keyword">WITH</span> <span class="keyword">SESSION</span> <span class="keyword">SHUTDOWN</span> <span class="keyword">SQL</span> clause must be specified <span class="keyword">to</span> perform a <span class="keyword">role</span> transition <span class="keyword">while</span> <span class="keyword">in</span> this state. <span class="keyword">On</span> a <span class="keyword">logical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, a <span class="keyword">role</span> transition can be performed <span class="keyword">while</span> <span class="keyword">in</span> this state, but the <span class="keyword">role</span> transition will <span class="keyword">not</span> <span class="keyword">complete</span> <span class="keyword">until</span> <span class="keyword">all</span> <span class="keyword">current</span> transactions have committed.</span><br><span class="line"><span class="keyword">SWITCHOVER</span> PENDING - <span class="keyword">On</span> a <span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that a <span class="keyword">switchover</span> request has been received <span class="keyword">from</span> the primary <span class="keyword">database</span> <span class="keyword">and</span> <span class="keyword">is</span> being processed. A <span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span> cannot <span class="keyword">switch</span> <span class="keyword">to</span> the primary <span class="keyword">role</span> <span class="keyword">while</span> <span class="keyword">in</span> this transient state.</span><br><span class="line"><span class="keyword">SWITCHOVER</span> LATENT - <span class="keyword">On</span> a <span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that a <span class="keyword">switchover</span> request was pending, but the original primary <span class="keyword">database</span> has been switched back <span class="keyword">to</span> the primary role.</span><br><span class="line"><span class="keyword">TO</span> PRIMARY - The <span class="keyword">database</span> <span class="keyword">is</span> ready <span class="keyword">to</span> <span class="keyword">switch</span> <span class="keyword">to</span> the primary role.</span><br><span class="line"><span class="keyword">TO</span> <span class="keyword">STANDBY</span> - The <span class="keyword">database</span> <span class="keyword">is</span> ready <span class="keyword">to</span> <span class="keyword">switch</span> <span class="keyword">to</span> either the <span class="keyword">physical</span> <span class="keyword">or</span> <span class="keyword">logical</span> <span class="keyword">standby</span> role.</span><br><span class="line"><span class="keyword">TO</span> <span class="keyword">LOGICAL</span> <span class="keyword">STANDBY</span> - The <span class="keyword">database</span> has received a <span class="keyword">data</span> dictionary <span class="keyword">from</span> a <span class="keyword">logical</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">and</span> <span class="keyword">is</span> ready <span class="keyword">to</span> <span class="keyword">switch</span> <span class="keyword">to</span> the <span class="keyword">logical</span> <span class="keyword">standby</span> role.</span><br><span class="line"><span class="keyword">RECOVERY</span> NEEDED - <span class="keyword">On</span> a <span class="keyword">physical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that additional <span class="keyword">redo</span> must be applied <span class="keyword">before</span> the <span class="keyword">database</span> can <span class="keyword">switch</span> <span class="keyword">to</span> the primary role.</span><br><span class="line">PREPARING <span class="keyword">SWITCHOVER</span> - <span class="keyword">On</span> a primary <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that a <span class="keyword">data</span> dictionary <span class="keyword">is</span> being received <span class="keyword">from</span> a <span class="keyword">logical</span> <span class="keyword">standby</span> <span class="keyword">database</span> <span class="keyword">in</span> preparation <span class="keyword">for</span> switching <span class="keyword">to</span> the <span class="keyword">logical</span> <span class="keyword">standby</span> role. <span class="keyword">On</span> a <span class="keyword">logical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that the <span class="keyword">data</span> dictionary has been sent <span class="keyword">to</span> the primary <span class="keyword">database</span> <span class="keyword">and</span> other <span class="keyword">standby</span> databases.</span><br><span class="line">PREPARING DICTIONARY - <span class="keyword">On</span> a <span class="keyword">logical</span> <span class="keyword">standby</span> <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that the <span class="keyword">data</span> dictionary <span class="keyword">is</span> being sent <span class="keyword">to</span> the primary <span class="keyword">database</span> <span class="keyword">and</span> other <span class="keyword">standby</span> <span class="keyword">databases</span> <span class="keyword">in</span> preparation <span class="keyword">for</span> switching <span class="keyword">to</span> the primary role.</span><br><span class="line"><span class="keyword">FAILED</span> DESTINATION - <span class="keyword">On</span> a primary <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that one <span class="keyword">or</span> more <span class="keyword">standby</span> destinations <span class="keyword">are</span> <span class="keyword">in</span> an <span class="keyword">error</span> state.</span><br><span class="line">RESOLVABLE GAP - <span class="keyword">On</span> a primary <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that one <span class="keyword">or</span> more <span class="keyword">standby</span> <span class="keyword">databases</span> have a <span class="keyword">redo</span> gap that can be automatically resolved <span class="keyword">by</span> fetching the <span class="keyword">missing</span> <span class="keyword">redo</span> <span class="keyword">from</span> the primary <span class="keyword">database</span> <span class="keyword">or</span> <span class="keyword">from</span> another <span class="keyword">standby</span> database.</span><br><span class="line">UNRESOLVABLE GAP - <span class="keyword">On</span> a primary <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that one <span class="keyword">or</span> more <span class="keyword">standby</span> <span class="keyword">databases</span> have a <span class="keyword">redo</span> gap that cannot be automatically resolved <span class="keyword">by</span> fetching the <span class="keyword">missing</span> <span class="keyword">redo</span> <span class="keyword">from</span> the primary <span class="keyword">database</span> <span class="keyword">or</span> <span class="keyword">from</span> another <span class="keyword">standby</span> database.</span><br><span class="line"><span class="keyword">LOG</span> <span class="keyword">SWITCH</span> GAP - <span class="keyword">On</span> a primary <span class="keyword">database</span>, this <span class="keyword">status</span> indicates that one <span class="keyword">or</span> more <span class="keyword">standby</span> <span class="keyword">databases</span> <span class="keyword">are</span> <span class="keyword">missing</span> <span class="keyword">redo</span> due <span class="keyword">to</span> a recent <span class="keyword">log</span> switch.</span><br></pre></td></tr></table></figure>

<ol start="13">
<li>关于延迟应用</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">方法1: 在备库应用主库日志的语句中指定delay属性</span><br><span class="line">如<span class="keyword">alter</span> <span class="keyword">database</span> <span class="keyword">recover</span> <span class="keyword">managed</span> <span class="keyword">standby</span> <span class="keyword">database</span> delay <span class="number">120</span> <span class="keyword">disconnect</span> <span class="keyword">from</span> <span class="keyword">session</span>;   <span class="comment">--备库延迟120分钟应用主库日志</span></span><br><span class="line">方法2: log_ archive_dest_n参数中指定了delay属性</span><br><span class="line"><span class="keyword">alter</span> <span class="keyword">system</span> <span class="keyword">set</span> log_archive_dest_2=<span class="string">'service=etyyhisdg lgwr sync delay=120 valid_for=(all_logfiles,all_roles) db_unique_name=etyyhisdg'</span>;</span><br></pre></td></tr></table></figure>

<ol start="14">
<li>清理过期的归档日志</li>
</ol>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">crosscheck archivelog all;                             <span class="comment">---&gt;校验日志的可用性</span></span><br><span class="line">list expired archivelog all;                           <span class="comment">---&gt;列出所有失效的归档日志</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">archivelog</span> <span class="keyword">until</span> <span class="keyword">sequence</span> <span class="number">16</span>;                   <span class="comment">---&gt;删除log sequence为16及16之前的所有归档日志</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">archivelog</span> <span class="keyword">all</span> completed <span class="keyword">before</span> <span class="string">'sysdate-7'</span>;    <span class="comment">---&gt;删除系统时间7天以前的归档日志，不会删除闪回区有效的归档日志</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">archivelog</span> <span class="keyword">all</span> completed <span class="keyword">before</span> <span class="string">'sysdate - 1'</span>;  <span class="comment">---&gt;同上，1天以前的</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">archivelog</span> <span class="keyword">from</span> <span class="built_in">time</span> <span class="string">'sysdate-1'</span>;               <span class="comment">---&gt;注意这个命令，删除系统时间1天以内到现在的归档日志</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">noprompt</span> <span class="keyword">archivelog</span> <span class="keyword">all</span> completed <span class="keyword">before</span> <span class="string">'sysdate'</span>;   <span class="comment">---&gt;该命令清除所有的归档日志</span></span><br><span class="line"><span class="keyword">delete</span> <span class="keyword">noprompt</span> <span class="keyword">archivelog</span> <span class="keyword">all</span>;                              <span class="comment">---&gt;同上一命令</span></span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://emoh.xyz/2020/05/27/2019-07-17-NBU%E5%BC%82%E6%9C%BA%E6%81%A2%E5%A4%8D/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.png">
      <meta itemprop="name" content="Emoh">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Just do it!">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/05/27/2019-07-17-NBU%E5%BC%82%E6%9C%BA%E6%81%A2%E5%A4%8D/" class="post-title-link" itemprop="url">NBU异机恢复</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-05-27 10:14:16" itemprop="dateCreated datePublished" datetime="2020-05-27T10:14:16+08:00">2020-05-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-28 11:29:26" itemprop="dateModified" datetime="2020-05-28T11:29:26+08:00">2020-05-28</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/veritas/" itemprop="url" rel="index"><span itemprop="name">veritas</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="注意事项-解决-NBU-2801错误"><a href="#注意事项-解决-NBU-2801错误" class="headerlink" title="注意事项,解决 NBU 2801错误"></a>注意事项,解决 NBU 2801错误</h1><h2 id="NBU恢复客户端需要关注-bp-conf-etc-hosts文件"><a href="#NBU恢复客户端需要关注-bp-conf-etc-hosts文件" class="headerlink" title="NBU恢复客户端需要关注 bp.conf /etc/hosts文件"></a>NBU恢复客户端需要关注 bp.conf /etc/hosts文件</h2><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line">bp.conf</span><br><span class="line">SERVER = backup251</span><br><span class="line">SERVER = madb1</span><br><span class="line">SERVER = madb2</span><br><span class="line">SERVER = gzdbsrv1</span><br><span class="line">SERVER = ysdbsrv2</span><br><span class="line">SERVER = tjdbsrv2</span><br><span class="line">SERVER = fmsdb34.minanins.com</span><br><span class="line">SERVER = cwdbsrv1</span><br><span class="line">CLIENT_NAME = weixindb2</span><br><span class="line">CONNECT_OPTIONS = localhost 1 0 2</span><br><span class="line">/etc/hosts</span><br></pre></td></tr></table></figure>




<h2 id="所有media-server-需要在-etc-hosts-解析恢复客户端"><a href="#所有media-server-需要在-etc-hosts-解析恢复客户端" class="headerlink" title="所有media server 需要在/etc/hosts 解析恢复客户端"></a>所有media server 需要在/etc/hosts 解析恢复客户端</h2><hr>
<h1 id="恢复数据库"><a href="#恢复数据库" class="headerlink" title="恢复数据库"></a>恢复数据库</h1><h2 id="1-从源库备份一个standby-控制文件恢复-（主要是catalog在控制文件）"><a href="#1-从源库备份一个standby-控制文件恢复-（主要是catalog在控制文件）" class="headerlink" title="1. 从源库备份一个standby 控制文件恢复 （主要是catalog在控制文件）"></a>1. 从源库备份一个standby 控制文件恢复 （主要是catalog在控制文件）</h2><p><code>backup current controlfile for standby format &#39;/oracle/backup/c_%T_%t.bak&#39;;</code></p>
<h2 id="2-在目标库恢复控制文件"><a href="#2-在目标库恢复控制文件" class="headerlink" title="2. 在目标库恢复控制文件"></a>2. 在目标库恢复控制文件</h2><p><code>restore controlfile from &#39;/oracle/backup/c_20190401_1004446688.bak&#39;;</code></p>
<h2 id="3-查找恢复用control-file"><a href="#3-查找恢复用control-file" class="headerlink" title="3.查找恢复用control file"></a>3.查找恢复用control file</h2><p><code>/usr/openv/netbackup/bin/bplist -S &#39;backup251&#39; -C &#39;weixindb1&#39; -t 4 -R -l / |more</code></p>
<h2 id="4-从NBU恢复控制文件"><a href="#4-从NBU恢复控制文件" class="headerlink" title="4.从NBU恢复控制文件"></a>4.从NBU恢复控制文件</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">RUN &#123;</span><br><span class="line">allocate channel D1 type SBT_TAPE;</span><br><span class="line">send &#39;NB_ORA_SERV&#x3D;backup251,NB_ORA_CLIENT&#x3D;weixindb1&#39;;</span><br><span class="line">RESTORE CONTROLFILE FROM &#39;cntrl_132375_1_988097540&#39;;</span><br><span class="line">RELEASE CHANNEL D1;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="5-还原和恢复数据库"><a href="#5-还原和恢复数据库" class="headerlink" title="5.还原和恢复数据库"></a>5.还原和恢复数据库</h2><figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">run &#123;</span><br><span class="line">allocate channel D1 type SBT_TAPE;</span><br><span class="line">allocate channel D2 type SBT_TAPE;</span><br><span class="line">allocate channel D3 type SBT_TAPE;</span><br><span class="line">allocate channel D4 type SBT_TAPE;</span><br><span class="line">send 'NB_ORA_SERV=backup251,NB_ORA_CLIENT=weixindb1';</span><br><span class="line"><span class="keyword">restore</span> <span class="keyword">database</span>;</span><br><span class="line">recover database;</span><br><span class="line"><span class="keyword">RELEASE</span> CHANNEL D1;</span><br><span class="line"><span class="keyword">RELEASE</span> CHANNEL D2;</span><br><span class="line"><span class="keyword">RELEASE</span> CHANNEL D3;</span><br><span class="line"><span class="keyword">RELEASE</span> CHANNEL D4;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="6-继续恢复数据库"><a href="#6-继续恢复数据库" class="headerlink" title="6.继续恢复数据库"></a>6.继续恢复数据库</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">RUN &#123;</span><br><span class="line">allocate channel D1 type SBT_TAPE;</span><br><span class="line">send &#39;NB_ORA_SERV&#x3D;backup251,NB_ORA_CLIENT&#x3D;weixindb1&#39;;</span><br><span class="line">recover database;</span><br><span class="line">RELEASE CHANNEL D1;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h2 id="7-启动备库日志应用-（如果是全新搭建还需要考虑参数文件，密码文件，文件目录，TNSNAME等配置）"><a href="#7-启动备库日志应用-（如果是全新搭建还需要考虑参数文件，密码文件，文件目录，TNSNAME等配置）" class="headerlink" title="7.启动备库日志应用 （如果是全新搭建还需要考虑参数文件，密码文件，文件目录，TNSNAME等配置）"></a>7.启动备库日志应用 （如果是全新搭建还需要考虑参数文件，密码文件，文件目录，TNSNAME等配置）</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">startup nomount</span><br><span class="line">alter database mount standby database;</span><br><span class="line">alter database recover managed standby database using current logfile disconnect from session;</span><br><span class="line">alter database recover managed standby database disconnect from session;</span><br></pre></td></tr></table></figure>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://emoh.xyz/2020/05/27/2019-07-17-ELK%206%20%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.png">
      <meta itemprop="name" content="Emoh">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Just do it!">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/05/27/2019-07-17-ELK%206%20%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2/" class="post-title-link" itemprop="url">ELK 6 安装部署</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2020-05-27 10:14:16" itemprop="dateCreated datePublished" datetime="2020-05-27T10:14:16+08:00">2020-05-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2020-05-28 11:29:24" itemprop="dateModified" datetime="2020-05-28T11:29:24+08:00">2020-05-28</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/elasticsearch/" itemprop="url" rel="index"><span itemprop="name">elasticsearch</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <ul>
<li>content<br>{:toc}</li>
</ul>
<h1 id="ELK安装"><a href="#ELK安装" class="headerlink" title="ELK安装"></a>ELK安装</h1><h2 id="1-JAVA安装"><a href="#1-JAVA安装" class="headerlink" title="1. JAVA安装"></a>1. JAVA安装</h2><ul>
<li><p>JAVA下载<br><a href="http://java.oracle.com" target="_blank" rel="noopener">http://java.oracle.com</a></p>
</li>
<li><p>java环境变量配置</p>
</li>
</ul>
<p><strong>编辑/etc/profile 或者 ~./bash_profile 添加以下配置</strong></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">export</span> PATH</span><br><span class="line"><span class="built_in">export</span> JAVA_HOME=/usr/java/jdk1.8.0_144/</span><br><span class="line"><span class="built_in">export</span> PATH=<span class="variable">$JAVA_HOME</span>/bin:<span class="variable">$PATH</span></span><br><span class="line"><span class="built_in">export</span> CLASSPATH=.:<span class="variable">$JAVA_HOME</span>/lib/dt.jar:<span class="variable">$JAVA_HOME</span>/lib/tools.jar:<span class="variable">$JAVA_HOME</span>/lib</span><br></pre></td></tr></table></figure>

<hr>
<h2 id="2-ELK下载"><a href="#2-ELK下载" class="headerlink" title="2. ELK下载"></a>2. ELK下载</h2><ul>
<li><p>官网<br><a href="https://www.elastic.co/cn/products/" target="_blank" rel="noopener">https://www.elastic.co/cn/products/</a></p>
</li>
<li><p>历史版本在这里<br><a href="https://www.elastic.co/downloads/past-releases" target="_blank" rel="noopener">https://www.elastic.co/downloads/past-releases</a></p>
</li>
<li><p>ES下载(6.4.2)<br><a href="https://www.elastic.co/downloads/past-releases/elasticsearch-6-4-2" target="_blank" rel="noopener">https://www.elastic.co/downloads/past-releases/elasticsearch-6-4-2</a></p>
</li>
<li><p>Logstash下载(6.4.2)<br><a href="https://www.elastic.co/downloads/past-releases/logstash-6-4-2" target="_blank" rel="noopener">https://www.elastic.co/downloads/past-releases/logstash-6-4-2</a></p>
</li>
<li><p>Kinaba下载(6.4.2)<br><a href="https://www.elastic.co/downloads/past-releases/kibana-6-4-2" target="_blank" rel="noopener">https://www.elastic.co/downloads/past-releases/kibana-6-4-2</a></p>
</li>
</ul>
<hr>
<h2 id="3-ES安装"><a href="#3-ES安装" class="headerlink" title="3. ES安装"></a>3. ES安装</h2><ul>
<li>上传</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /opt/elk/soft</span><br><span class="line">上传 elasticsearch-6.4.2.tar.gz</span><br></pre></td></tr></table></figure>

<ul>
<li>解压</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /opt/elk/soft</span><br><span class="line">tar xvf elasticsearch-6.4.2.tar.gz /opt/elk/</span><br><span class="line">ls -l /opt/elk/</span><br></pre></td></tr></table></figure>

<ul>
<li>创建用户（必需）</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">groupadd elasticsearch</span><br><span class="line">useradd elasticsearch -g elasticsearch -p elasticsearch</span><br><span class="line"><span class="built_in">cd</span> /opt/elk/</span><br><span class="line">chown -R elasticsearch.elasticsearch ./elasticsearch-6.4.2/</span><br></pre></td></tr></table></figure>

<p>/etc/security/limit.conf</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">elasticsearch   soft    nofile  65536</span><br><span class="line">elasticsearch   hard    nofile  65536</span><br><span class="line">elasticsearch   hard    nproc   4096</span><br><span class="line">elasticsearch   soft    nproc   4096</span><br></pre></td></tr></table></figure>

<ul>
<li>配置<br>创建data目录</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p /<span class="built_in">log</span>/es/es6/</span><br><span class="line"><span class="built_in">cd</span> /<span class="built_in">log</span></span><br><span class="line">chown -R elasticsearch.elasticsearch ./es</span><br></pre></td></tr></table></figure>

<p>编辑配置文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">[root@elksrv01 config]<span class="comment"># cat elasticsearch.yml  | grep -v  ^#  |grep -v ^$</span></span><br><span class="line">cluster.name: apiins</span><br><span class="line">node.name: node0</span><br><span class="line">path.data: /<span class="built_in">log</span>/es/es6/data</span><br><span class="line">path.logs: /<span class="built_in">log</span>/es/es6/<span class="built_in">log</span></span><br><span class="line">bootstrap.memory_lock: <span class="literal">false</span></span><br><span class="line">bootstrap.system_call_filter: <span class="literal">false</span></span><br><span class="line">network.host: 172.10.5.3</span><br><span class="line">http.port: 9200</span><br></pre></td></tr></table></figure>

<ul>
<li>启动,关闭,重启脚本</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">[root@elksrv01 init.d]<span class="comment"># cat elasticsearch</span></span><br><span class="line"><span class="meta">#!/bin/sh</span></span><br><span class="line"><span class="comment">#chkconfig: 2345 80 05</span></span><br><span class="line"><span class="comment">#description: elasticsearch</span></span><br><span class="line"> </span><br><span class="line"><span class="built_in">export</span> JAVA_HOME=/usr/java/jdk1.8.0_144</span><br><span class="line"><span class="built_in">export</span> JAVA_BIN=/usr/java/jdk1.8.0_144/bin</span><br><span class="line"><span class="built_in">export</span> PATH=<span class="variable">$PATH</span>:<span class="variable">$JAVA_HOME</span>/bin</span><br><span class="line"><span class="built_in">export</span> CLASSPATH=.:<span class="variable">$JAVA_HOME</span>/lib/dt.jar:<span class="variable">$JAVA_HOME</span>/lib/tools.jar</span><br><span class="line"><span class="built_in">export</span> JAVA_HOME JAVA_BIN PATH CLASSPATH</span><br><span class="line"> </span><br><span class="line"><span class="keyword">case</span> <span class="string">"<span class="variable">$1</span>"</span> <span class="keyword">in</span></span><br><span class="line">start)</span><br><span class="line">    su elasticsearch&lt;&lt;!</span><br><span class="line">    <span class="built_in">cd</span> /opt/elk/elasticsearch-6.4.2</span><br><span class="line">    ./bin/elasticsearch -d</span><br><span class="line">!</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"elasticsearch startup"</span></span><br><span class="line">    ;;  </span><br><span class="line">stop)</span><br><span class="line">    es_pid=`ps aux|grep elasticsearch | grep -v <span class="string">'grep elasticsearch'</span> | awk <span class="string">'&#123;print $2&#125;'</span>`</span><br><span class="line">    <span class="built_in">kill</span> -9 <span class="variable">$es_pid</span></span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"elasticsearch stopped"</span></span><br><span class="line">    ;;  </span><br><span class="line">restart)</span><br><span class="line">    es_pid=`ps aux|grep elasticsearch | grep -v <span class="string">'grep elasticsearch'</span> | awk <span class="string">'&#123;print $2&#125;'</span>`</span><br><span class="line">    <span class="built_in">kill</span> -9 <span class="variable">$es_pid</span></span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"elasticsearch stopped"</span></span><br><span class="line">    su elasticsearch&lt;&lt;!</span><br><span class="line">    <span class="built_in">cd</span> /opt/elk/elasticsearch-6.4.2</span><br><span class="line">    ./bin/elasticsearch -d</span><br><span class="line">!</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"elasticsearch startup"</span></span><br><span class="line">    ;;  </span><br><span class="line">*)</span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"start|stop|restart"</span></span><br><span class="line">    ;;  </span><br><span class="line"><span class="keyword">esac</span></span><br><span class="line"><span class="built_in">exit</span> $?</span><br></pre></td></tr></table></figure>

<ul>
<li>验证<br>浏览器访问<a href="http://172.10.5.3:9200/" target="_blank" rel="noopener">http://172.10.5.3:9200/</a><br>返回</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&#123;</span><br><span class="line">  <span class="string">"name"</span> : <span class="string">"node0"</span>,</span><br><span class="line">  <span class="string">"cluster_name"</span> : <span class="string">"apiins"</span>,</span><br><span class="line">  <span class="string">"cluster_uuid"</span> : <span class="string">"LxLnkqDBQm2NBXvHS3PZ4g"</span>,</span><br><span class="line">  <span class="string">"version"</span> : &#123;</span><br><span class="line">    <span class="string">"number"</span> : <span class="string">"6.4.2"</span>,</span><br><span class="line">    <span class="string">"build_flavor"</span> : <span class="string">"default"</span>,</span><br><span class="line">    <span class="string">"build_type"</span> : <span class="string">"tar"</span>,</span><br><span class="line">    <span class="string">"build_hash"</span> : <span class="string">"04711c2"</span>,</span><br><span class="line">    <span class="string">"build_date"</span> : <span class="string">"2018-09-26T13:34:09.098244Z"</span>,</span><br><span class="line">    <span class="string">"build_snapshot"</span> : <span class="literal">false</span>,</span><br><span class="line">    <span class="string">"lucene_version"</span> : <span class="string">"7.4.0"</span>,</span><br><span class="line">    <span class="string">"minimum_wire_compatibility_version"</span> : <span class="string">"5.6.0"</span>,</span><br><span class="line">    <span class="string">"minimum_index_compatibility_version"</span> : <span class="string">"5.0.0"</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="string">"tagline"</span> : <span class="string">"You Know, for Search"</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ul>
<li>问题</li>
</ul>
<hr>
<h2 id="4-Logstash安装"><a href="#4-Logstash安装" class="headerlink" title="4. Logstash安装"></a>4. Logstash安装</h2><ul>
<li>上传</li>
<li>解压</li>
<li>配置</li>
<li>启动</li>
<li>screen命令<br><a href="https://www.ibm.com/developerworks/cn/linux/l-cn-screen/" target="_blank" rel="noopener">https://www.ibm.com/developerworks/cn/linux/l-cn-screen/</a></li>
<li>验证</li>
</ul>
<h2 id="5-Kinaba安装"><a href="#5-Kinaba安装" class="headerlink" title="5. Kinaba安装"></a>5. Kinaba安装</h2><ul>
<li>上传</li>
<li>解压</li>
<li>配置</li>
<li>启动</li>
<li>验证</li>
</ul>
<h2 id="6-nginx日志分析"><a href="#6-nginx日志分析" class="headerlink" title="6. nginx日志分析"></a>6. nginx日志分析</h2><ul>
<li>nginx日志配置</li>
<li>filebeat配置</li>
<li>Logstash配置</li>
<li>GeoIP</li>
<li>Kinaba展示</li>
<li>效果图</li>
</ul>
<h2 id="7-syslog日志分析"><a href="#7-syslog日志分析" class="headerlink" title="7. syslog日志分析"></a>7. syslog日志分析</h2><ul>
<li>syslog.conf配置</li>
<li>Logstash配置</li>
<li>验证</li>
</ul>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://emoh.xyz/2020/05/25/2020-05-25-%E5%AE%B9%E5%99%A8%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/touxiang.png">
      <meta itemprop="name" content="Emoh">
      <meta itemprop="description" content="">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Just do it!">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/2020/05/25/2020-05-25-%E5%AE%B9%E5%99%A8%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/" class="post-title-link" itemprop="url">容器常用操作</a>
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2020-05-25 12:54:53 / 修改时间：13:15:38" itemprop="dateCreated datePublished" datetime="2020-05-25T12:54:53+08:00">2020-05-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/docker/" itemprop="url" rel="index"><span itemprop="name">docker</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="命令分布图"><a href="#命令分布图" class="headerlink" title="命令分布图"></a>命令分布图</h1><p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512114627057-1589272553499.png" alt="image-20200512114627057"></p>
<h1 id="镜像相关"><a href="#镜像相关" class="headerlink" title="镜像相关"></a>镜像相关</h1><ul>
<li><p>搜索镜像</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker search *image_name*</span><br></pre></td></tr></table></figure>
</li>
<li><p>下载镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker pull *image_name*</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker images</span><br><span class="line">docker image ls</span><br></pre></td></tr></table></figure>
</li>
<li><p>删除镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker rmi *image_name*</span><br><span class="line">docker image rm *image_name*</span><br></pre></td></tr></table></figure>
</li>
<li><p>导出镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker save *image_name* &gt; /save/image/path/name.tar.gz</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>导入镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker load &lt; /save/image/path/name.tar.gz</span><br></pre></td></tr></table></figure>
</li>
<li><p>提交创建的自定义镜像</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">docker commit *container_id* *镜像名称*</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line">[root@c7-dev ~]<span class="comment"># docker images</span></span><br><span class="line">REPOSITORY TAG IMAGE ID CREATED SIZE</span><br><span class="line">docker.io/centos latest 1e1148e4cc2c 6 days ago 202 MB</span><br><span class="line">docker.io/ubuntu latest 93fd78260bd1 3 weeks ago 86.2 MB</span><br><span class="line">docker.io/hello-world latest 4ab4c602aa5e 3 months ago 1.84 kB</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">6ecddae6e645 centos <span class="string">"bash"</span> 21 minutes ago Exited (0) About a minute ago boring_mestorf</span><br><span class="line"><span class="comment"># 进入容器，执行一些安装的过程省略</span></span><br><span class="line"><span class="comment"># 对容器进行一些自定制的操作后，提交这个容器生成新的镜像</span></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker commit 6ecdd gandoufu/centos-wget</span></span><br><span class="line">sha256:bac2d675a9c230f0a60b0af35b5d4e3cb337d7c6f122a05b60a9172ddb9fbda0</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">6ecddae6e645 centos <span class="string">"bash"</span> 24 minutes ago Exited (0) 4 minutes ago boring_mestorf</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker images</span></span><br><span class="line">REPOSITORY TAG IMAGE ID CREATED SIZE</span><br><span class="line">gandoufu/centos-wget latest bac2d675a9c2 16 seconds ago 328 MB</span><br><span class="line">docker.io/centos latest 1e1148e4cc2c 6 days ago 202 MB</span><br><span class="line">docker.io/ubuntu latest 93fd78260bd1 3 weeks ago 86.2 MB</span><br><span class="line">docker.io/hello-world latest 4ab4c602aa5e 3 months ago 1.84 kB</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将生成的新的镜像推送至远程仓库</span></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker login</span></span><br><span class="line">Username: gandoufu</span><br><span class="line">Password:</span><br><span class="line">Login Succeeded</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker images</span></span><br><span class="line">REPOSITORY TAG IMAGE ID CREATED SIZE</span><br><span class="line">gandoufu/centos-wget latest bac2d675a9c2 10 minutes ago 328 MB</span><br><span class="line">docker.io/centos latest 1e1148e4cc2c 6 days ago 202 MB</span><br><span class="line">docker.io/ubuntu latest 93fd78260bd1 3 weeks ago 86.2 MB</span><br><span class="line">docker.io/hello-world latest 4ab4c602aa5e 3 months ago 1.84 kB</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker tag bac2 gandoufu/centos7-wget:latest</span></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker images</span></span><br><span class="line">REPOSITORY TAG IMAGE ID CREATED SIZE</span><br><span class="line">gandoufu/centos-wget latest bac2d675a9c2 12 minutes ago 328 MB</span><br><span class="line">gandoufu/centos7-wget latest bac2d675a9c2 12 minutes ago 328 MB</span><br><span class="line">docker.io/centos latest 1e1148e4cc2c 6 days ago 202 MB</span><br><span class="line">docker.io/ubuntu latest 93fd78260bd1 3 weeks ago 86.2 MB</span><br><span class="line">docker.io/hello-world latest 4ab4c602aa5e 3 months ago 1.84 kB</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker push gandoufu/centos7-wget</span></span><br><span class="line">The push refers to a repository [docker.io/gandoufu/centos7-wget]</span><br><span class="line">f79b6b9e2fa6: Pushing [==================================================&gt;] 129.6 MB</span><br><span class="line">071d8bd76517: Pushed</span><br><span class="line"></span><br><span class="line">打标签时的注意事项：</span><br><span class="line">docker tag bac2 gandoufu/centos7-wget</span><br><span class="line">bac2 是镜像的id</span><br><span class="line">gandoufu/centos7-wget 镜像的名称必须是自己的id名称/镜像名称</span><br><span class="line">latest 默认版本号，可以不用加</span><br></pre></td></tr></table></figure>



</li>
</ul>
<h1 id="容器相关"><a href="#容器相关" class="headerlink" title="容器相关"></a>容器相关</h1><ul>
<li><p>创建容器</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">docker create image_name</span><br><span class="line">docker create -t -i image_name bash</span><br><span class="line">docker run image_name</span><br><span class="line">docker run image_name /bin/<span class="built_in">echo</span> “haha”</span><br><span class="line">docker run -it -d image_name</span><br><span class="line">docker run -it -d –rm –name mydo image_name</span><br><span class="line"></span><br><span class="line">使用create创建的容器，在使用时需要先start对应的容器；</span><br><span class="line">使用run创建的容器，直接运行；如果指定的image_name不存在，则会去镜像仓库下载镜像，然后根据镜像创建容器。</span><br><span class="line"></span><br><span class="line">参数说明：</span><br><span class="line">i 进入交互模式</span><br><span class="line">t 创建一个虚拟终端</span><br><span class="line">d 后台运行</span><br><span class="line">rm 退出后自动删除容器</span><br><span class="line">name 创建的容器使用自定义的名字</span><br><span class="line">注：i和t参数一起指定（-it），在实际操作时发现只指定i参数时，attach到实例时会出现卡死的情况。</span><br></pre></td></tr></table></figure>
</li>
<li><p>进入容器</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker attach *container_id|container_name*</span><br><span class="line">根据容器的id或名字进入指定的容器；如果容器处于未运行状态，需要先启动容器docker start container_id</span><br></pre></td></tr></table></figure>

<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 22 minutes ago Exited (0) 3 seconds ago hungry_franklin</span><br><span class="line">[root@c7-dev ~]<span class="comment">#</span></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker start aefe</span></span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker attach aefe</span></span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 20 minutes ago Up 16 seconds hungry_franklin</span><br></pre></td></tr></table></figure>
</li>
<li><p>使用运行的容器执行命令</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">docker exec *container_id* command</span><br><span class="line">[root@c7-dev ~]# docker ps</span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos &quot;bash&quot; 15 minutes ago Up 15 minutes hungry_franklin</span><br><span class="line">[root@c7-dev ~]# docker exec aefe date</span><br><span class="line">Wed Dec 12 14:04:12 UTC 2018</span><br></pre></td></tr></table></figure>
</li>
<li><p>查看容器</p>
  <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">docker psdocker ps -adocker ps -aq</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker run -it -d centos bash</span></span><br><span class="line">aefe7162ed163028c36741c26545dc0f1967ada0c985ce32cee5cf79666d2a3b</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker create -it --name myubun ubuntu</span></span><br><span class="line">3ba687940aed4a65bfc0656ea23ab627eab71ec4c3bd796ab107674503dd6f72</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 45 seconds ago Up 45 seconds hungry_franklin</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">3ba687940aed ubuntu <span class="string">"/bin/bash"</span> 9 seconds ago Created myubun</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 47 seconds ago Up 47 seconds hungry_franklin</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -aq</span></span><br><span class="line">3ba687940aed</span><br><span class="line">aefe7162ed16</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>停止容器</p>
  <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">docker stop *container_id*</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 18 minutes ago Up 18 minutes hungry_franklin</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker stop aefe</span></span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>删除容器</p>
  <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">docker rm *container_id*</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">3ba687940aed ubuntu <span class="string">"/bin/bash"</span> 16 minutes ago Created myubun</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 17 minutes ago Up 17 minutes hungry_franklin</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker rm myubun</span></span><br><span class="line">myubun</span><br><span class="line">[root@c7-dev ~]<span class="comment"># docker ps -a</span></span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">aefe7162ed16 centos <span class="string">"bash"</span> 17 minutes ago Up 17 minutes hungry_franklin</span><br></pre></td></tr></table></figure>



</li>
</ul>
<h1 id="仓库相关"><a href="#仓库相关" class="headerlink" title="仓库相关"></a>仓库相关</h1><ul>
<li><p>登录/退出仓库</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">docker login/<span class="built_in">logout</span></span><br><span class="line"></span><br><span class="line">[root@docker163 ~]<span class="comment"># docker login</span></span><br><span class="line">Login with your Docker ID to push and pull images from Docker Hub. If you don<span class="string">'t have a Docker ID, head over to https://hub.docker.com to create one.</span></span><br><span class="line"><span class="string">Username: xiaowenli</span></span><br><span class="line"><span class="string">Password:</span></span><br><span class="line"><span class="string">Error response from daemon: Get https://registry-1.docker.io/v2/: unauthorized: incorrect username or password</span></span><br><span class="line"><span class="string">[root@docker163 ~]# docker login</span></span><br><span class="line"><span class="string">Login with your Docker ID to push and pull images from Docker Hub. If you don'</span>t have a Docker ID, head over to https://hub.docker.com to create one.</span><br><span class="line">Username: xiaowenli</span><br><span class="line">Password:</span><br><span class="line">WARNING! Your password will be stored unencrypted <span class="keyword">in</span> /root/.docker/config.json.</span><br><span class="line">Configure a credential helper to remove this warning. See</span><br><span class="line">https://docs.docker.com/engine/reference/commandline/login/<span class="comment">#credentials-store</span></span><br><span class="line"></span><br><span class="line">Login Succeeded</span><br><span class="line">[root@docker163 ~]<span class="comment"># docker logout</span></span><br><span class="line">Removing login credentials <span class="keyword">for</span> https://index.docker.io/v1/</span><br></pre></td></tr></table></figure>



</li>
</ul>
<h1 id="外部访问容器"><a href="#外部访问容器" class="headerlink" title="外部访问容器"></a>外部访问容器</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">先下载一个training&#x2F;webapp镜像，用于测试</span><br><span class="line">[root@c7-dev ~]# docker run -d -P training&#x2F;webapp python app.py</span><br><span class="line">e8c1832a9814d61c61faf3d472b40c1164cd410caad855415f3bc56668f0cc2a</span><br><span class="line">[root@c7-dev ~]# docker ps</span><br><span class="line">CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES</span><br><span class="line">e8c1832a9814 training&#x2F;webapp &quot;python app.py&quot; 4 seconds ago Up 3 seconds 0.0.0.0:32768-&gt;5000&#x2F;tcp tender_cori</span><br><span class="line">[root@c7-dev ~]# docker port e8c</span><br><span class="line">5000&#x2F;tcp -&gt; 0.0.0.0:32768</span><br><span class="line">[root@c7-dev ~]# docker top e8c1</span><br><span class="line">UID PID PPID C STIME TTY TIME CMD</span><br><span class="line">root 1781 1767 0 10:19 ? 00:00:00 python app.py</span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]# docker run -d -p 8000:5000 --name flask training&#x2F;webapp python app.py</span><br><span class="line">fef819097329bf7eb90fcf868a4a047b39e62b300c7e30105c38d1adf7fbf10e</span><br><span class="line">[root@c7-dev ~]# docker port fef8</span><br><span class="line">5000&#x2F;tcp -&gt; 0.0.0.0:8000</span><br><span class="line">通过webapp镜像创建运行容器，在容器内运行一个简单的web应用，端口为5000。</span><br><span class="line"></span><br><span class="line">参数说明：</span><br><span class="line">-P 会使用宿主机的一个随机端口映射到容器内的5000端口；外部访问ip+随机端口就可以访问容器内的外部应用</span><br><span class="line">-p 指定外部端口与内部端口映射关系。外部端口:内部端口</span><br></pre></td></tr></table></figure>



<h1 id="硬件资源相关"><a href="#硬件资源相关" class="headerlink" title="硬件资源相关"></a>硬件资源相关</h1><ul>
<li><p>创建容器的时候，限制内存</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@c7-dev ~]# docker run -it -d -m 100M --memory-swap -1 --name mycent centos</span><br><span class="line">32d70771e7c88b70caaca4c8e7428421a0906dde6358d77441104a6162032447</span><br><span class="line">[root@c7-dev ~]# docker stats --no-stream 32d7</span><br><span class="line">CONTAINER CPU % MEM USAGE &#x2F; LIMIT MEM % NET I&#x2F;O BLOCK I&#x2F;O PIDS</span><br><span class="line">32d7 0.00% 380 KiB &#x2F; 100 MiB 0.37% 648 B &#x2F; 648 B 0 B &#x2F; 0 B 1</span><br></pre></td></tr></table></figure>



</li>
</ul>
<ul>
<li><p>更新内存限制</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line">[root@c7-dev ~]# docker update -m 200M --memory-swap -1 32d7</span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]#</span><br><span class="line">[root@c7-dev ~]#</span><br><span class="line">[root@c7-dev ~]# docker stats --no-stream 32d7</span><br><span class="line">CONTAINER CPU % MEM USAGE &#x2F; LIMIT MEM % NET I&#x2F;O BLOCK I&#x2F;O PIDS</span><br><span class="line">32d7 0.00% 380 KiB &#x2F; 200 MiB 0.19% 648 B &#x2F; 648 B 0 B &#x2F; 0 B 1</span><br><span class="line"></span><br><span class="line">[root@c7-dev ~]# docker update -m 400M 32d7</span><br><span class="line">Error response from daemon: Cannot update container 32d70771e7c88b70caaca4c8e7428421a0906dde6358d77441104a6162032447: Memory limit should be smaller than already set memoryswap limit, update the memoryswap at the same time</span><br><span class="line"></span><br><span class="line">注意：指定限制内存大小并且设置 memory-swap 值为 -1，表示容器程序使用内存受限，而 swap 空间使用不受限制（宿主 swap 支持使用多少则容器即可使用多少。如果 –memory-swap 设置小于 –memory则设置不生效，使用默认设置）。</span><br><span class="line">docker run -it --rm -m 100M ubuntu-stress:latest &#x2F;bin&#x2F;bash</span><br><span class="line">如果不添加–memory-swap选项，则表示容器中程序可以使用100M内存和100Mswap内存，默认情况下，–memory-swap 会被设置成 memory 的 2倍。-m 为物理内存上限，而 –memory-swap 则是 memory + swap 之和，当压测值是 –memory-swap 上限时，则容器中的进程会被直接 OOM kill。</span><br></pre></td></tr></table></figure>



</li>
</ul>
<h1 id="命令参考表"><a href="#命令参考表" class="headerlink" title="命令参考表"></a>命令参考表</h1><p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150614123-1589272560575.png" alt="image-20200512150614123"></p>
<p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150633190-1589272562024.png" alt="image-20200512150633190"></p>
<p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150805510-1589272563919.png" alt="image-20200512150805510"></p>
<p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150831873-1589272566726.png" alt="image-20200512150831873"></p>
<p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150850949-1589272568967.png" alt="image-20200512150850949"></p>
<img src="http://wenlixiao.gitee.io/md/pic/1328551-20181213140747902-888532965-1589272570727.png" alt="img" style="zoom:200%;" />

<p><img src="http://wenlixiao.gitee.io/md/pic/image-20200512150954304-1589272572894.png" alt="image-20200512150954304"></p>

      
    </div>

    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/page/4/"><i class="fa fa-angle-left" aria-label="上一页"></i></a><a class="page-number" href="/">1</a><span class="space">&hellip;</span><a class="page-number" href="/page/4/">4</a><span class="page-number current">5</span>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Emoh"
      src="/images/touxiang.png">
  <p class="site-author-name" itemprop="name">Emoh</p>
  <div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">29</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">16</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Emoh</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
